﻿@model CommonHelper.Model.Qy.GetDepartmentList
@{
    ViewBag.Title = "部门列表";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@if (Model != null)
{
    <table style="width: 100%;border: 1px solid #006400">
        <tr>
            <th>部门Id</th>
            <th>部门名称</th>
            <th>次序值</th>
            <th>父部门Id</th>
            <th>操作</th>
        </tr >
        @foreach (var item in Model.department)
        {
            <tr style="text-align: center ;">
                <td>@item.id</td>
                <td>@item.name</td>
                <td>@item.order</td>
                <td>@item.parentid</td>
                <td><a href="#" onclick="UpdateDept(@item.id)">更新</a></td>
                <td><a href="#" onclick="DeleletDept(@item.id)">删除</a></td>
            </tr>
        }
    </table>
}
<script type="text/javascript">
    function Search() {
        var accessToken = $("#accessToken").val();
        $.ajax({
            url: "/Department/List",
            type: "get",
            data: { "accessToken": accessToken },
            success: function () {
                //window.location.href = "/Department/List";
            }
        });
    }

    function UpdateDept(id) {
        $.ajax({
            url: "/Department/Update",
            type: "get",
            data: {"id":id},
            success: function() {
                window.location.href = "/Department/Update";
            }
        });
    }

    function DeleletDept(id) {
        $.ajax({
            url: "/Department/Delete",
            type: "post",
            data: {"id":id},
            success: function(res) {
                alert(res);
                window.location.href = "/Department/List";
            }
        });
    }
</script>

<style type="text/css">
    table td {
        border: 1px solid #006400;
    }
</style>